package com.hnqcgczy.supplier.service.impl;

import com.hnqcgczy.supplier.dao.EvaluateDao;
import com.hnqcgczy.supplier.dao.impl.EvaluateDaoImpl;
import com.hnqcgczy.supplier.db.MyTransaction;
import com.hnqcgczy.supplier.service.EvaluateService;
import com.hnqcgczy.supplier.vo.Evaluate;
import com.hnqcgczy.supplier.vo.EvaluateVo;

import java.sql.SQLException;
import java.util.List;

public class EvaluateServiceImpl implements EvaluateService {
    private MyTransaction myTransaction = new MyTransaction(true);
    private EvaluateDao evaluateDao = new EvaluateDaoImpl(myTransaction);

    @Override
    public boolean add(Evaluate evaluate) throws SQLException {
        return evaluateDao.add(evaluate) > 0;
    }

    @Override
    public boolean update(Evaluate evaluate) throws SQLException {
        return evaluateDao.update(evaluate) > 0;
    }

    @Override
    public boolean delete(Integer evaluateId) throws SQLException {
        return evaluateDao.delete(evaluateId) > 0;
    }

    @Override
    public EvaluateVo findOne(Integer evaluateId) throws SQLException {
        return evaluateDao.findOne(evaluateId);
    }

    @Override
    public List<EvaluateVo> findByLike(EvaluateVo evaluateVo, int pageNow, int pageSize) throws SQLException {
        int start = (pageNow - 1) * pageSize;

        return evaluateDao.findByLike(evaluateVo, start, pageSize);
    }

    @Override
    public int totals(EvaluateVo evaluateVo) throws SQLException {
        return evaluateDao.totals(evaluateVo);
    }
}
